// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers

import (
	"github.com/beego/beego/v2/server/web"
	"github.com/beego/beego/v2/server/web/filter/cors"
	"ltbz/cultural_tourism_api/controllers"
	"ltbz/cultural_tourism_api/controllers/financial"
	"ltbz/cultural_tourism_api/controllers/system"
)

func init() {
	web.InsertFilter("*", web.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins:  true,
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: true,
	}))

	ns := web.NewNamespace("/api",
		web.NSNamespace("/auth",
			web.NSInclude(
				&controllers.AuthController{},
			),
		),
		web.NSNamespace("/system",
			web.NSInclude(
				&system.SysRoleController{},
				&system.SysUserController{},
				&system.SysMenuController{},
				&system.SysDeptController{},
				&system.SysConfigController{},
				&system.SysDataAuthController{},
			),
		),
		web.NSNamespace("/common",
			web.NSInclude(
				&controllers.CommonController{},
			),
		),
		web.NSNamespace("/xcx",
			web.NSInclude(
				&system.SysXcxBannerController{},
			),
		),
		web.NSNamespace("/scenic_spot",
			web.NSInclude(
				&controllers.ScenicSpotController{},
			),
		),
		web.NSNamespace("/operator",
			web.NSInclude(
				&controllers.OperatorController{},
			),
		),
		web.NSNamespace("/financial",
			web.NSInclude(
				&financial.ImperialPalaceController{},
				&financial.CooperateScenicController{},
			),
		),
		web.NSNamespace("/reserve_manage",
			web.NSInclude(
				&controllers.ReserveManageController{},
			),
		),
	)
	web.AddNamespace(ns)
}
